
package com.lee.utils; 
 
import com.lee.source.HbaseSource; 
 
import java.io.IOException; 
import java.text.SimpleDateFormat; 
import java.util.Date; 
 
public class CrowdFlowUtils { 
    private static String tableName = "marketing:crowd_flow";
    private static String family = "info";
    private static String custIdQualifier = "cust_id";
    private static String nameQualifier = "name";
    private static String activityCodeQualifier = "activity_code";
    private static String activityNameQualifier = "activity_name";
    private static String dsQualifier = "ds";
    private static String timeQualifier = "time";
    public static void initMap() throws IOException {
        HbaseSource.truncate(tableName);
    }
 
    public static boolean judgeKeyInMap(String cust_id,String time) throws IOException {
        String rowKey = time + " " + cust_id;
        String result = HbaseSource.get(rowKey,tableName,family,custIdQualifier);
        if(! "".equals(result)){
            return true;
        }else {
            return false;
        }
 
    }
 
    public static void setValueByKey(String cust_id,String name,String activityCode,String activityName,String time) throws IOException {
        Date date = new Date();
        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String currentTime  = dateFormat.format(date);
        String rowKey = time + " " + cust_id;
        HbaseSource.put(rowKey,tableName,family,custIdQualifier,cust_id);
        HbaseSource.put(rowKey,tableName,family,nameQualifier,name);
        HbaseSource.put(rowKey,tableName,family,activityCodeQualifier,activityCode);
        HbaseSource.put(rowKey,tableName,family,activityNameQualifier,activityName);
        HbaseSource.put(rowKey,tableName,family,dsQualifier,currentTime);
        HbaseSource.put(rowKey,tableName,family,timeQualifier,time);
 
    }
 
 
 
 
 
} 
